 <template>
   <el-card shadow="always" class="box-card">
      <div class="card-name">
        <div class="name width2">仓储报表</div>
      </div>
      <div class="content-con">
        <el-form :model="form" ref="form" size="medium" label-width="80px" class="flex-s">
          <el-form-item label="日期:" prop="date">
            <el-date-picker
              v-model="form.date"
              type="date"
              format="yyyy-MM-dd"
              placeholder="日期"
              style="width: 100%;">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="商品:" prop="goods">
            <el-input v-model="form.goods" clearable placeholder="商品">
              <el-button size="mini" slot="append" icon="el-icon-search" @click="openGoods"></el-button>
            </el-input>
          </el-form-item>
          <el-form-item><el-button class="save" @click="search()">查 询</el-button></el-form-item>
        </el-form>

        <div class="bank-form">
          <div class="form-item">
            <el-table
              :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
              class="table"
              stripe border
              :header-cell-style="{background:'#f3f3f3',textAlign: 'center'}"
              :cell-style="{ textAlign: 'center' }">
              <el-table-column prop="goods_no" label="商品编号" width="160">
              </el-table-column>
              <el-table-column prop="goods" label="商品名称" width="120">
              </el-table-column>
              <el-table-column prop="model" label="规格型号" width="100">
              </el-table-column>
              <el-table-column prop="unit" label="单位" width="100">
              </el-table-column>
              <el-table-column label="所有仓库">
                <el-table-column prop="all_amount" label="数量" width="120">
                </el-table-column>
                <el-table-column prop="all_cost" label="成本" width="120">
                </el-table-column>
              </el-table-column>
              <el-table-column label="郑州">
                <el-table-column prop="z_amount" label="数量" width="120">
                </el-table-column>
                <el-table-column prop="z_cost" label="成本" width="120">
                </el-table-column>
              </el-table-column>
              <el-table-column label="南宁仓库">
                <el-table-column prop="n_amount" label="数量" width="120">
                </el-table-column>
                <el-table-column prop="n_cost" label="成本" width="120">
                </el-table-column>
              </el-table-column>
              <el-table-column label="梧州仓库">
                <el-table-column prop="w_amount" label="数量" width="120">
                </el-table-column>
                <el-table-column prop="w_cost" label="成本" width="120">
                </el-table-column>
              </el-table-column>
            </el-table>
          </div>
          <!-- 分页-页码 -->
          <div class="page">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[5, 10, 15, 20]"
              :page-size="pagesize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="tableData.length">
            </el-pagination>
          </div>
        </div>
      </div>
      <modal-goods ref="ModalGoods"></modal-goods>
   </el-card>

 </template>
<script>
import ModalGoods from '@/components/purchasing-system/ModalGoods';
export default {
  components: {
    ModalGoods
  },
  data () {
    return {
      currentPage: 1, //当前页码
      pagesize: 5,    //每页的数据条数
      //tableData: [], //表格数据
      tableData: [
        {
          goods_no: '12015',
          goods: '葡萄',
          model: '',
          unit: '箱',
          all_amount: '4',
          all_cost: '200',
          z_amount: '2',
          z_cost: '100',
          n_amount: '2',
          n_cost: '100',
          w_amount: '0',
          w_cost: '0'
        }
      ],
      form: {
        date: '',
        goods: ''
      }
    }
  },

  methods: {
    //搜索
    search() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          console.log(this.form)
          this.$message.success('成功!');
        } else {
          console.log('error submit!!');
          this.$message.error('失败!');
          return false;
        }
      });
    },

    //商品-对话框
    openGoods() {
      this.$nextTick(()=>{
        this.$refs.ModalGoods.openGood();
      });
    },

    //每页条数改变时触发事件,选择一页显示多少行
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.currentPage = 1;
      this.pagesize = val;
    },
    // 当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    }
  }
}
</script>
<style lang="scss">

</style>
